



layui.use(['form', 'layer', 'jquery', 'layedit', 'laydate'], function () {
    var form = layui.form,
        layer = parent.layer === undefined ? layui.layer : parent.layer,
        laypage = layui.laypage,
        layedit = layui.layedit,
        laydate = layui.laydate,
        jquery = layui.jquery;

    jquery("#login").click(function () {
        var index = top.layer.msg('正在登录，请稍候', {icon: 16, time: false, shade: 0.8});
        var contactalias= jquery("#contactalias").val();
        var password=jquery("#password").val()
        jquery.ajax({
            url: "/user/login?contactalias="+contactalias+"&password="+password+"&userAgent="+bro()
            , type: "post"
            , success: function (result) {
                if (result.data !=null) {
                    layer.close(index)
                    top.layer.msg("用户添加成功！");
                    location.href = "/enter/firstadmin";
                } else {
                    layer.close(index)
                    top.layer.msg("用户添加失败！");
                }
            }
        });

    })





















    function bro() {
        var is360 = false;
        var isIE = false;
        var isFirefox = false;
        var isChrome = false;
        var isEdge = false;
        var broName = 'Runing';
        var str = '';
        var strStart = 0;
        var strStop = 0;
        var arr = new Array();
        var temp = '';

        var userAgent = window.navigator.userAgent; //包含以下属性中所有或一部分的字符串：appCodeName,appName,appVersion,language,platform

        /*alert(userAgent);*/

        //FireFox
        if (userAgent.indexOf('Firefox') != -1) {
            isFireFox = true;
            /*broName = 'FireFox浏览器';*/
            strStart = userAgent.indexOf('Firefox');
            temp = userAgent.substring(strStart);
            broName = temp.replace('/', '版本号')

        }

        //Edge
        if (userAgent.indexOf('Edge') != -1) {
            isEdge = true;
            /*broName = 'Edge浏览器';*/
            strStart = userAgent.indexOf('Edge');
            temp = userAgent.substring(strStart);
            broName = temp.replace('/', '版本号');
        }

        //IE浏览器
        if (userAgent.indexOf('NET') != -1 && userAgent.indexOf("rv") != -1) {
            isIE = true;
            /*broName = 'IE浏览器'; */
            strStart = userAgent.indexOf('rv');
            strStop = userAgent.indexOf(')');
            temp = userAgent.substring(strStart, strStop);
            broName = temp.replace('rv', 'IE').replace(':', '版本号');
        }

        //360极速模式可以区分360安全浏览器和360极速浏览器
        if (userAgent.indexOf('WOW') != -1 && userAgent.indexOf("NET") < 0 && userAgent.indexOf("Firefox") < 0) {
            if(navigator.javaEnabled()){
                is360 = true;
                broName = '360安全浏览器-极速模式';
            }else{
                is360 = true;
                broName = '360极速浏览器-极速模式';
            }
        }

        //360兼容
        if (userAgent.indexOf('WOW') != -1 && userAgent.indexOf("NET") != -1 && userAgent.indexOf("MSIE") != -1 && userAgent.indexOf("rv") < 0) {
            is360 = true;
            broName = '360兼容模式';
        }

        //Chrome浏览器
        if (userAgent.indexOf('WOW') < 0 && userAgent.indexOf("Edge") < 0) {
            isChrome = true;
            /*broName = 'Chrome浏览器';*/
            strStart = userAgent.indexOf('Chrome');
            strStop = userAgent.indexOf(' Safari');
            temp = userAgent.substring(strStart, strStop);
            broName = temp.replace('/', '版本号');

        }

        return  broName;
    }













    

})